//
//  QrCodeViewController.m
//  PrintPort
//
//  Created by hy002 on 2017/12/26.
//  Copyright © 2017年 HUAYU. All rights reserved.
//

#import "QrCodeViewController.h"
#import "UIImage+LXDCreateBarcode.h"

@interface QrCodeViewController ()

@end

@implementation QrCodeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatUI];
}

- (void)creatUI
{
    self.navigationController.navigationBar.translucent = NO;
    self.view.backgroundColor = BacksColor;
    self.navigationItem.title = @"我的邀请码";
    //    UIImage * image = [UIImage imageOfQRFromURL:_urlStr codeSize: 1000 red: 0 green: 0 blue: 0 insertImage:_image roundRadius: 15.0f];
    //    CGSize size = image.size;
    //    UIImageView * imageView = [[UIImageView alloc] initWithFrame:  ((CGRect){(CGPointZero), (size)})];
    //    CGPoint point = self.view.center;
    //    point.y -= 100;
    //    imageView.center = point;
    //    imageView.image = image;
    //    [self.view addSubview: imageView];
    UIImage *image = [self dataURL2Image:_urlStr];
    UIImageView *imageview = [ZCControl createImageViewWithFrame:CGRectMake(60*displaywidth, 100*displaywidth, SCREEN_WIDTH-120*displaywidth, SCREEN_WIDTH-120*displaywidth) ImageName:@""];
    imageview.image = image;
    imageview.contentMode = UIViewContentModeScaleAspectFill;
    imageview.layer.masksToBounds = YES;
    [self.view addSubview:imageview];
    
    UILabel *tostLab = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, SCREEN_WIDTH-10*displaywidth, SCREEN_WIDTH-30*displaywidth, 30*displaywidth) Font:20.0 Text:@"印港在线" Color:BlaTiColor];
    tostLab.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:tostLab];
}

- (UIImage *) dataURL2Image: (NSString *) imgSrc
{
    //    NSURL *url = [NSURL URLWithString: imgSrc];
    //    NSData *data = [NSData dataWithContentsOfURL: url];
    //    UIImage *image = [UIImage imageWithData: data];
    NSData *imageData = [[NSData alloc] initWithBase64EncodedString:imgSrc options:NSDataBase64DecodingIgnoreUnknownCharacters];
    UIImage *image = [UIImage imageWithData:imageData];
    return image;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
